def consumer():
    r = ''
    while True:
        print('before yield')
        n = yield r
        print('after yield %s' % n)
        if not n:
            return
        print('[CONSUMER] Consuming %s...' % n)
        r = '200 OK'

def produce(c):
    print('before c.send None')
    c.send(None)
    print('after c.send None')
    n = 0
    while n < 5:
        n = n + 1
        print('[PRODUCER] Producing %s...' % n)
        r = c.send(n)
        print('[PRODUCER] Consumer return: %s' % r)
    c.close()

print('before consumer execute')
c = consumer()
print('after consumer execute')
produce(c)
print('after produce(c) execute')

def simple_coroutine():
    while True:
        print('-> start')
        x = yield
        print('-> recived', x)

sc = simple_coroutine()

print(next(sc))
sc.send('zhexiao')